package com.mvvm.start.lib_login.mvvm.vm

import androidx.lifecycle.MutableLiveData
import com.mvvm.start.base.bean.UserInfoResult
import com.mvvm.start.base.base.BaseViewModel
import com.mvvm.start.lib_login.bean.to.LoginTo
import com.mvvm.start.lib_login.mvvm.m.LoginRegisteredRepository

/**
 * @author lmy
 * @功能: 登录界面
 * @Creat 2021/4/8 10:02 上午
 * @Compony 465008238@qq.com
 */

class LoginViewModle : BaseViewModel() {
    val isshowProgress = MutableLiveData<Boolean>()
    val userBean = MutableLiveData<UserInfoResult>()

    /**
     * 登录提交
     */
    fun submitLogin(name: String, pwd: String, phone: String? = "", code: String? = "") {
        var loginTo = LoginTo(name, pwd)
        loginTo.name = name
        loginTo.pwd = pwd
        loginTo.phone = phone
        loginTo.code = code
        checkResult {
            userBean.postValue(LoginRegisteredRepository.login(loginTo))
        }
    }
}

